package org.calzz.rpc.envelope;

/**
 * @author Marek Brodziak <marek.brodziak@gmail.com>
 * @author Piotr Pejas <piotr.pejas@gmail.com>
 * @since Mar 8, 2008
 */
public enum JsonInvocationError {
	// TODO resource bundle
	SERVER_ERROR(100, "Server error"), 
	PARSE_ERROR(200, "Parse error"), 
	BAD_CALL(300, "Bad call"), 
	CALL_MEMBER_OUT_OF_SEQUENCE(400, "Call member out of sequence"), 
	SERVICE_ERROR(500, "Service error"), 
	PROCEDURE_NOT_FOUND(600, "Procedure not found");

	private final static String name = "JSONRPCError";
	private final String message;
	private final int code;
	private JsonExceptionEnvelope error;

	JsonInvocationError(int code, String message) {
		this.message = message;
		this.code = code;
	}

	/**
	 * @return
	 */
	public int getCode() {
		return code;
	}

	/**
	 * @return
	 */
	public String getMessage() {
		return message;
	}

	/**
	 * @return
	 */
	public String getName() {
		return name;
	}

	/**
	 * @return
	 */
	public JsonExceptionEnvelope getError() {
		return error;
	}

	/**
	 * @param error
	 */
	public void setError(JsonExceptionEnvelope error) {
		this.error = error;
	}
}
